<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    body{
      height: 1000px;
    }
    #di{
      width: 200px;
      height: 200px;
      margin: 100px;
      background-color: blue;
    }
  </style>
</head>
<body>
  <div id="di"></div>
  <script>
    var di = document.getElementById("di");
    di.onclick = function (e) {
      e = e || window.event
      // client鼠标距离浏览器窗口左上角的距离
      console.log(e.clientX);
      console.log(e.clientY);
      // page鼠标相对于整个html左上角的距离
      console.log(e.pageX);
      console.log(e.pageY);
    }
    
  </script>
</body>
</html>